package com.wallet.trans.controller;

import com.wallet.trans.resp.BaseResp;
import com.wallet.trans.utils.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@Slf4j
public class CallBackController {
    @Autowired
    private RedisUtils redisUtils;

    @GetMapping("/info")
    public BaseResp<Object> getInfo(@RequestParam("id") String id) {
        String key = "transCallback:";
        return BaseResp.ok(redisUtils.get(key + id));
    }

    @PostMapping("/info")
    public BaseResp<Boolean> setInfo(@RequestBody Map<String, String> paramsMap) {
        String key = "transCallback:" + paramsMap.get("serialNo");
        return BaseResp.ok(redisUtils.set(key,paramsMap,7200));
    }
}
